# _*_ coding: utf-8 _*_
# @Time     : 2022/7/16 16:24
# @Author   : dake
# @Email    : dake@2545923.com
# @File     : tjfx_cw.py
# @Software : PyCharm
from selenium.webdriver.common.by import By
from pages.base_page import BasePage
import unittest


class CwTongJi(BasePage):
    """验证财务统计切换"""
    url = "http://192.168.1.5:8081/crm/index.php?m=finance&a=analytics"  # 财务统计页面url
    table = "table table-hover"
    yuedu = "财务信息月度统计"
    shoukuan = "应收款年度同比"  # 断言判断
    fukuan = "应付款年度同比"
    """定位器"""
    show_report_locator = (By.ID, "show_report")  # 财务统计报表
    show_moon_locator = (By.ID, "show_moon")  # 月度统计
    show_shoukuan_locator = (By.ID, "show_shoukuan")  # 应收款年度同比
    show_fukuan_locator = (By.ID, "show_fukuan")  # 应付款年度同比
    table_locator = (By.CSS_SELECTOR, "#report_content > table")  # 断言cw统计报表
    yuedu_locator = (By.CSS_SELECTOR, "#highcharts-0 > svg > text.highcharts-title")
    shoukuan_locator = (By.CSS_SELECTOR, "#highcharts-2 > svg > text.highcharts-title")
    fukuan_locator = (By.CSS_SELECTOR, "#highcharts-4 > svg > text.highcharts-title")

    def moon_clic(self):
        """点击月度统计"""
        self.driver.find_element(*self.show_moon_locator).click()

    def shoukuan_clic(self):
        """点击应收款年度同比"""
        self.driver.find_element(*self.show_shoukuan_locator).click()

    def fukuan_clic(self):
        """点击应付款同比"""
        self.driver.find_element(*self.show_fukuan_locator).click()

    def report_clic(self):
        """点击财务统计报表"""
        self.driver.find_element(*self.show_report_locator).click()

    def get_cla(self):
        """获取切换到财务统计报表页面的元素的class"""
        return self.driver.find_element(*self.table_locator).get_attribute("class")

    def get_text1(self):
        """获取当前页面的判断切换到月度统计的元素的文本"""
        return self.driver.find_element(*self.yuedu_locator).text

    def get_text2(self):
        """获取当前页面的判断切换到收款的元素的文本"""
        return self.driver.find_element(*self.shoukuan_locator).text

    def get_text3(self):
        """获取当前页面的判断切换到付款统计的元素的文本"""
        return self.driver.find_element(*self.fukuan_locator).text

if __name__ == "__main__":
    unittest.main()
